	$(window).ready(function() {
		initClickEvent();
	});
function zTreeOnClick(event, treeId, treeNode) {
	FormUtils.convertSimpleObject2Form(treeNode.targetObject,
			"searchFormRegion")
};

function initClickEvent() {
	$('#saveBtnRegion').bind('click',function(){
		var dwrOption = {
				callback : function(result) {
					var treeObj = $.fn.zTree.getZTreeObj("divTree");
					FormUtils.clearForm("searchFormRegion");
					alert("save success!!");
					treeObj.reAsyncChildNodes(null, "refresh");
				
				}
			}
		var region = FormUtils.convertSimpleForm2Object(
				"searchFormRegion", null);
		if(region.demoRegionId !=null&&region.demoRegionId.length>0)
		RegionService.updateDemoRegion(region, $.DwrUtils.proDwrOption(dwrOption));
		else
			RegionService.addDemoRegion(region, $.DwrUtils.proDwrOption(dwrOption));
	});
	
	$('#deleteBtnRegion').bind('click',function(){
		var dwrOption = {
				callback : function(result) {
					var treeObj = $.fn.zTree.getZTreeObj("divTree");
					alert("delete success!!");
					treeObj.reAsyncChildNodes(null, "refresh");
				
				}
			}
		RegionService.removeDemoRegion(FormUtils.convertSimpleForm2Object(
					"searchFormRegion", null), $.DwrUtils.proDwrOption(dwrOption));
	});
	$('#clearBtnRegion').bind('click',function(){
		FormUtils.clearForm("searchFormRegion");
	});
};

function ajaxDataFilter(treeId, parentNode, childNodes) {
    if (childNodes) {
      for(var i =0; i < childNodes.length; i++) {
        childNodes[i].open =true ;
      }
    }
    return childNodes;
};
function exampleDataFilter(treeId, parentNode, childNodes){
   
    return childNodes;
}
